import { ClientMessage } from "@runtime/generate/message/ClientMessage";
import { computed, ComputedRef, reactive, ref, Ref, UnwrapNestedRefs } from "vue";
import ExamComponent from "./ExamComponent";

export const Modules: ComputedRef<Array<{ Id: number, Name: string, Description: string, Label: string, Icon: string }>> = computed(() => {
    const configs = [
        { Id: 5, Name: 'Calibration', Description: '毫米波雷达', Label: '毫米波雷达应用', Icon: 'ic_menu_5' },
        { Id: 6, Name: 'Protocol', Description: '毫米波雷达', Label: '毫米波雷达协议解读', Icon: 'ic_menu_6' },
        { Id: 7, Name: 'Usage', Description: '双目相机', Label: '双目相机应用', Icon: 'ic_menu_7' },
    ];

    const types = ExamComponent.Default.Types.value;

    return configs.filter(config => types.includes(config.Description));
});

export default class ExamSettings {
    private static instance: UnwrapNestedRefs<ExamSettings> = reactive(new ExamSettings());
    /**
     * 双目相机组件
     */
    public static get Default(): UnwrapNestedRefs<ExamSettings> {
        return this.instance;
    }

    public Title: string = '智能网联汽车赛项';

    public Name: string = '用户名';

    public Module: Ref<string> = ref('');

    public MillimeterWaveRadarDeviceIndex: number = 0;
    public MillimeterWaveRadarDeviceType: number = 4;
    public MillimeterWaveRadarCanIndex: number = 0;
    public BaseInformation = reactive(new ClientMessage.MillimeterWaveRadarBaseInformation());

    public DeviceStatus: string = '';
}